import sys
a = []
x = 1
b = input()
a = b.split(sep=" ")
c = str()
s = 0
s1 = 0
trigger = 0
if len(a) == 3:
    for i in range(3):
        if a[i] == "zero":
            c += "0"
        elif a[i] == "one":
            c += "1"
        elif a[i] == "two":
            c += "2"
        elif a[i] == "three":
            c += "3"
        elif a[i] == "four":
            c += "4"
        elif a[i] == "five":
            c += "5"
        elif a[i] == "six":
            c += "6"
        elif a[i] == "seven":
            c += "7"
        elif a[i] == "eight":
            c += "8"
        elif a[i] == "nine":
            c += "9"
        else:
            print("Wrong input")
            sys.exit()
    c=int(c)
    box = c
    outp0=0
    outp1=0
    while(trigger != 1):
        for i in range(1,box+1):
            if box%i==0:
                outp0=box
                s+=1
        if s==2:
            outp0=box
            trigger+=1
        elif s<2:
            outp0=2
            trigger+=1
        else:
            box=box-1
            s=0
    trigger=0
    box=c
    while(trigger != 1):
        for i in range(1,1000):
            if box%i==0:
                outp1=box
                s1+=1
        if s1==2:
            outp1=box
            trigger+=1
        elif s1<2:
            outp1=2
            trigger+=1
        else:
            box=box+1
            s1=0
    
    if abs(c-outp0)<=abs(c-outp1):
        print(outp0)
    elif abs(c-outp0)>abs(c-outp1):
        print(outp1)
    else:
        print(2)
else:
    print("Wrong input")              
